<?php

namespace Yiru\LaravelComposer;

use Illuminate\Support\ServiceProvider;
use Yiru\LaravelComposer\Console\Commands\ComposerInstall;
use Yiru\LaravelComposer\Console\Commands\ComposerRemove;

class ComposerServiceProvider extends ServiceProvider
{
    const PACKAGE = 'composer';
    
    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {
        $this->publishes([
            __DIR__.'/../config/'.self::PACKAGE.'.php' => config_path(self::PACKAGE.'.php')
        ],'config');

        $this->mergeConfigFrom(
            __DIR__.'/../config/'.self::PACKAGE.'.php', 'composer'
        );
        // $this->loadRoutesFrom(__DIR__.'/routes.php');
        //$this->loadMigrationsFrom(__DIR__.'/path/to/migrations');
        // $this->loadTranslationsFrom(__DIR__.'/path/to/translations', 'courier');

        // $this->publishes([
        //     __DIR__.'/path/to/translations' => resource_path('lang/vendor/courier'),
        // ]);
        // $this->loadViewsFrom(__DIR__.'/path/to/views', 'courier');
    }
    
    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        $this->mergeConfigFrom(
           __DIR__.'/../config/'.self::PACKAGE.'.php', config_path(self::PACKAGE.'.php')
        );
        //register the commands
        if ($this->app->runningInConsole()) {
            $this->commands([
                ComposerInstall::class,
                ComposerRemove::class
            ]);
        }        
    }

    
}
